<!--  -->
<template>
    <view class="">
        <view class="list-item">
            <image :src="row.img" />
            <view class="list-item-info">
                <view class="list-item-title">{{ row.name }}</view>
                <view>种植时间：{{ row.time }}</view>
                <view>作物：{{ row.cp }}</view>
                <view>品种：{{ row.type }}</view>
                <view>已添加批次：{{ row.num }}</view>
            </view>
        </view>
        <view style="margin-top: 40px; background-color: #fff; padding: 0 40rpx">
            <view class="suyuan">
                <view class="shuyuan_title">批次1</view>
                <view class="suyuan_num">溯源码 2024052010001</view>
                <view class="shuyuan_btn" @click="onShowCode('2024052010001')">查看</view>
            </view>
            <view class="suyuan">
                <view class="shuyuan_title">批次2</view>
                <view class="suyuan_num">溯源码 2024052010002</view>
                <view class="shuyuan_btn" @click="onShowCode('2024052010002')">查看</view>
            </view>
            <view class="suyuan">
                <view class="shuyuan_title">批次2</view>
                <view class="suyuan_num">溯源码 2024052010003</view>
                <view class="shuyuan_btn" @click="onShowCode('2024052010003')">查看</view>
            </view>
        </view>
        <u-popup :show="show" @close="close" mode="center" :closeable="true">
            <view style="padding: 50rpx"
                ><uqrcode
                    ref="uqrcode"
                    canvas-id="qrcode"
                    :value="code"
                    :options="{ margin: 10 }"
                ></uqrcode
            ></view>
        </u-popup>
    </view>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';

export default {
    //import引入的组件需要注入到对象中才能使用
    components: {},
    data() {
        //这里存放数据
        return {
            row: {},
            code: "123",
            show: false,
        };
    },
    onLoad(opt) {
        if (opt.row) {
            this.row = JSON.parse(decodeURIComponent(opt.row));
        }
    },
    //方法集合
    methods: {
        close() {
            this.show = false;
        },
        onShowCode(code) {
            this.show = true;
            this.code = code;
        },
    },
};
</script>
<style lang="scss" scoped>
.suyuan {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 120rpx;
    border-bottom: 1rpx solid #eee;
    font-size: 32rpx;
    line-height: 32rpx;
    .suyuan_num {
        flex: 2;
        margin-left: 16rpx;
        color: #999;
    }
    .shuyuan_title {
        flex-shrink: 0;
        font-size: 32rpx;
        color: #333;
        font-weight: 700;
        line-height: 32rpx;
    }
    .shuyuan_btn {
        color: #1296db;
    }
}
.list-item {
    margin-top: 40rpx;
    background-color: #fff;
    display: flex;
    padding: 40rpx;
    &-info {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        color: #777;
        .list-item-title {
            font-size: 34rpx;
            color: #555;
            font-weight: 700;
        }
    }
    image {
        width: 240rpx;
        height: 240rpx;
        margin-right: 24rpx;
    }
}
</style>
